home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / itrns211.zip / SRC / ITOPS.C < prev    next >
C/C++ Source or Header  |  1991-10-13  |  4KB  |  114 lines

  1. /*
  2.  *========================================================================== 
  3.  * Copyright 1991 Avinash Chopde, All Rights Reserved.
  4.  *
  5.  * Permission to use, copy, modify and distribute this software and its
  6.  * documentation for any purpose is hereby granted without fee, provided that
  7.  * the above copyright notice appear in all copies and that both that
  8.  * copyright notice and this permission notice appear in supporting
  9.  * documentation, and that the name of Avinash Chopde not be used in
  10.  * advertising or publicity pertaining to distribution of the software
  11.  * without specific, written prior permission.
  12.  * Avinash Chopde makes no representations about the suitability of this
  13.  * software for any purpose.
  14.  * It is provided "as is" without express or implied warranty.
  15.  *
  16.  * AVINASH CHOPDE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  17.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  18.  * IN NO EVENT SHALL AVINASH CHOPDE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  19.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  20.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  21.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  22.  * OF THIS SOFTWARE.
  23.  *
  24.  * Author:  Avinash Chopde, 1991
  25.  *        C2 Colonial Drive #4, Andover, MA 01810, USA.
  26.  *
  27.  */
  28.  
  29. static char S_RCSID[] = "$Header: e:/itrans/src/rcs/itops.c 1.3 91/10/13 16:50:43 avinash Exp $";
  30.  
  31. #include "itrans.h"
  32.  
  33. /* =================================================================== */
  34. /* =================================================================== */
  35. int cus_to_ps(comp_unit_t* cus, /* chain of PostScript Chars to output */
  36.           int fsize,
  37.           char pscomm[]) /* the postscript commands returned here */
  38. {
  39.     int dx, dy, pcode;
  40.  
  41.     strcpy(pscomm, "(");
  42.     pscomm += strlen(pscomm); /* point to start to next segment */
  43.  
  44.     while (cus) {
  45.     dx = cus->deltax;
  46.     dy = cus->deltay;
  47.     pcode = cus->u_pschar;
  48.  
  49. #ifdef DEBUG
  50. fprintf(stderr, "tops: constructing char: dx %d dy %d pcode %d\n", dx, dy, pcode);
  51. #endif /*DEBUG*/
  52.  
  53.     if (dx != 0 || dy != 0) {
  54.         if (*(pscomm - 1) == '(') *--pscomm = '\0';
  55.         else {
  56.         sprintf(pscomm, ") show ");
  57.         pscomm += strlen(pscomm);
  58.         }
  59.  
  60.         sprintf(pscomm, "%.3f %s %.3f %s rmoveto (",
  61.             dx / 1000.0, EMTOPS, dy / 1000.0, EMTOPS);
  62.         pscomm += strlen(pscomm);
  63.         
  64.     }
  65.  
  66.     if (pcode != NO_PSCHAR) {
  67.         if (isprint(pcode)) *pscomm++ = pcode;
  68.         else { 
  69.         sprintf(pscomm, "\\%03o", pcode);
  70.         pscomm += strlen(pscomm);
  71.         }
  72.     }
  73.     
  74.     /* if any Y movement was made, restore back the correct
  75.      * Y coordinate (the baseline)
  76.      */
  77.     if (dy != 0) {
  78.         if (*(pscomm - 1) == '(') *--pscomm = '\0';
  79.         else {
  80.         sprintf(pscomm, ") show ");
  81.         pscomm += strlen(pscomm);
  82.         }
  83.  
  84.         sprintf(pscomm, "%.3f %s %.3f %s rmoveto (",
  85.             0.0, EMTOPS, - dy / 1000.0, EMTOPS);
  86.         pscomm += strlen(pscomm);
  87.     }
  88.  
  89.  
  90.     cus = cus->next;
  91.     } /* while cus */
  92.  
  93.     if (*(pscomm - 1) == '(') *--pscomm = '\0';
  94.     else {
  95.     sprintf(pscomm, ") show ");
  96.     pscomm += strlen(pscomm);
  97.     }
  98.     strcpy(pscomm, "\n");
  99.     return TRUE;
  100. }
  101. /* =================================================================== */
  102. int outps_start(int fsize)
  103. {
  104.     printf("/%s %d def /endy endy %s sub def 50 endy moveto\n",
  105.             EMSIZE, fsize, EMSIZE);
  106.     return TRUE;
  107. }
  108. int outps_end()
  109. {
  110.     printf("\nshowpage\n");
  111.     return TRUE;
  112. }
  113. /* ============================^ itops.c ^ =========================== */
  114.